#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#define LL long long
#define nextLine() {int c = 0; while ((c = getchar()) != EOF && c != 10);}
#define sqr(a) ((a) * (a))
#define fill(a, c) memset(a, c, sizeof a)
#define ldb long double
#define sgn(a) ((a) > eps ? 1 : -1)
const ldb eps = 1e-9;
const ldb pi = fabs(atan2(0.0, -1.0));
const int INF = 1 << 28;
const LL LINF = 1ll << 50;
const ldb LDINF = 1e70;
const ldb cos3 = cos(pi / 3);
const ldb sin3 = sin(pi / 3);
using namespace std;
#define file "b"


int a, b;

void Load()
{
	cin >> a >> b;
}

void Solve()
{
	if (a == 0 && b == 0)
	{
		cout << 1 << "\n";
		return;
	}
	else if (a == 0)
	{
		cout << 0.5 << "\n";
		return;
	}
	else if (b == 0)
	{
		cout << 1 << "\n";
		return;
	}


	int up = min(4 * b, a);
	ldb res = 0;
	res = (ldb)up * up / ((ldb)16 * a * b) + up / (ldb)(2 * a);
	if (4 * b < a)
	{
		res += ((ldb)a - 4 * b)/(ldb)a;
	}
	cout << setprecision(15) << fixed << res << "\n";

}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(file".in", "rt", stdin);
	freopen(file".out", "wt", stdout);
	#endif
	int t;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		Load();
		Solve();
	}
	return 0;
}